package com.example.forum_system.exception;

import com.example.forum_system.common.AppResult;

/**
 * Created with IntelliJ IDEA.
 * Description: 自定义一个异常类，对于可预见的异常都抛出自定义的异常，可以为异常设置一个定义好的错误
 * User: Li_yizYa
 * Date: 2025/4/25
 * Time: 15:42
 */
public class ApplicationException extends RuntimeException {

    // 在异常中持有一个错误信息对象
    protected AppResult errorResult;

    /**
     * 构造方法
     * @param errorResult
     */
    public ApplicationException(AppResult errorResult) {
        super(errorResult.getMessage());
        this.errorResult = errorResult;
    }

    public ApplicationException(String message) {
        super(message);
    }

    public ApplicationException(String message, Throwable cause) {
        super(message, cause);
    }

    public ApplicationException(Throwable cause) {
        super(cause);
    }

    public AppResult getErrorResult() {
        return errorResult;
    }

}
